package org.a020;

import java.util.concurrent.TimeUnit;

public class ReentrantLock1 {
	synchronized void m1(){
		for(int i=0; i<10; i++) {
			try {
				TimeUnit.SECONDS.sleep(1);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(i);
		}
	}
	synchronized void m2(){
		System.out.println("m2...");
	}
	public static void main(String[] args) {
		ReentrantLock1 lock = new ReentrantLock1();
		new Thread(lock::m1).start();
		try {
			TimeUnit.SECONDS.sleep(1);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		new Thread(lock::m2).start();
	}
}
